package com.server.core;

import java.io.File;
import java.io.IOException;
import org.eclipse.jetty.util.resource.Resource;
import org.eclipse.jetty.webapp.WebAppClassLoader;
import org.eclipse.jetty.webapp.WebAppContext;

class ServerClassLoader extends WebAppClassLoader {

    private boolean initialized = false;

    public ServerClassLoader(WebAppContext context, String classPath) throws IOException {
        super(context);
        if (classPath != null) {
            String[] tokens = classPath.split(String.valueOf(File.pathSeparatorChar));
            String[] arrayOfString1;
            int j = (arrayOfString1 = tokens).length;
            for (int i = 0; i < j; i++) {
                String entry = arrayOfString1[i];
                String path = entry;
                if ((path.startsWith("-y-")) || (path.startsWith("-n-"))) {
                    path = path.substring(3);
                }
                if (!entry.startsWith("-n-")) {
                    super.addClassPath(path);
                }
            }
        }
        this.initialized = true;
    }

    public Class loadClass(String name) throws ClassNotFoundException {
        try {
            return loadClass(name, false);
        } catch (NoClassDefFoundError e) {
            throw new ClassNotFoundException(name);
        }
    }

    public void addClassPath(String classPath) throws IOException {
        if ((this.initialized) &&
                (!classPath.endsWith("WEB-INF/classes/"))) {
            return;
        }
        super.addClassPath(classPath);
    }

    public void addJars(Resource jars) {
        if (this.initialized) {
            return;
        }
        super.addJars(jars);
    }
}
